package com.zhuwentao.contorller;

import com.github.pagehelper.PageInfo;
import com.zhuwentao.entity.LiuShui;
import com.zhuwentao.service.LiuShuiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class LiuShuiContorller {
   @Autowired
    LiuShuiService liuShuiService;

   @RequestMapping("list")
    public String List(LiuShui liuShui, Model model, @RequestParam(defaultValue = "1") Integer pageNum,@RequestParam(defaultValue = "3") Integer pageSize){
       PageInfo<LiuShui> info=liuShuiService.list(liuShui,pageNum,pageSize);
       model.addAttribute("l",liuShui);
       model.addAttribute("info",info);
       return "list";
   }

   @RequestMapping("toadd")
    public String ToAdd(){
       return "add";
   }

   @ResponseBody
   @RequestMapping("add")
    public int Add(LiuShui liuShui){
       int i=liuShuiService.add(liuShui);
       return i;
   }

    @ResponseBody
    @RequestMapping("selectyuanname")
    public List<LiuShui> selectYuanName(String yuanname){
        List<LiuShui> list=liuShuiService.selectYuanname(yuanname);
        return list;
    }
}
